-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Simplify REPL #3560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify REPL #3560
Conversation
- Remove monadic API when not needed: methods returning `Result[T]` now return `T` if failure is not possible - Other minor polishing
cc8ab97
to
a1c776d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Not sure I get why you're changing the print of Nil though.
val B: List[Int] = Nil | ||
val C: List[Int] = Nil | ||
val B: List[Int] = List() | ||
val C: List[Int] = List() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
@@ -72,12 +73,12 @@ object Show { | |||
|
|||
implicit def showList[T](implicit st: Show[T]): Show[List[T]] = new Show[List[T]] { | |||
def show(xs: List[T]) = | |||
if (xs.isEmpty) "Nil" | |||
if (xs.isEmpty) "List()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
else "List(" + xs.map(_.show).mkString(", ") + ")" | ||
} | ||
|
||
implicit val showNil: Show[Nil.type] = new Show[Nil.type] { | ||
def show(xs: Nil.type) = "Nil" | ||
def show(xs: Nil.type) = "List()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is what scalac does:
scala> List()
res0: List[Nothing] = List()
scala> List(1, 2)
res1: List[Int] = List(1, 2)
I think it is more consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
¯\__(ツ)_/¯
Sounds like a debate for the ages. I'm definitely fine with the change, just wanted to know if there was some other motive beside the superficial one :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purely superficial =)
Result[T]
now returnT
if failure is not possible